package cn.com.bluemoon.daps.standard.entity;

import cn.com.bluemoon.daps.common.domain.BaseModel;
import cn.com.bluemoon.daps.common.enums.DatabaseType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Objects;

/**
 * <p>
 * 数据库字段基础类型数据表
 * </p>
 *
 * @author admin
 * @since 2020-08-07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors
@ApiModel(value = "DapStandardDataType", description = "数据库字段基础类型数据表")
public class DapStandardDataType extends BaseModel<DapStandardDataType> {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "标准数据类型对应同一数据库允许使用的字段类型")
    private String code;

    @ApiModelProperty(value = "数据类型, eg: 0: 代码类,1: 标志类,2: 文本类,3: 金额类,4: 比例类,5: 数值类,6: 日期类,7: 日期时间类,8: 时间类")
    private Integer codeType;

    @ApiModelProperty(value = "数据库类型，1:mysql 2:pgsql 3:hive")
    private DatabaseType dbType;

    @ApiModelProperty(value = "默认选择的数据类型")
    private String defaultVal;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DapStandardDataType that = (DapStandardDataType) o;
        return Objects.equals(code, that.code) && Objects.equals(codeType, that.codeType) && dbType == that.dbType && Objects.equals(defaultVal, that.defaultVal);
    }

    @Override
    public int hashCode() {
        return Objects.hash(code, codeType, dbType, defaultVal);
    }
}
